/**
 * #详见https://cli.vuejs.org/zh/config/#vue-config-js  baseURL
 * baseUrl 项目的根目录地址
 * 上传到服务器如果不在根目录下就需要配置
 */

const path = require('path')

module.exports = {
    baseUrl: process.env.VUE_APP_BASE,

    chainWebpack: config => {
        const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
        types.forEach(type => addStyleResource(config.module.rule('stylus').oneOf(type)))
    },

    css: {
      loaderOptions: {
        stylus: {
          'resolve url': true,
          'import': [
            './src/cubeui/theme'
          ]
        }
      }
    },

    pluginOptions: {
      'cube-ui': {
        postCompile: true,
        theme: true
      }
    }
}

function addStyleResource (rule) {
    rule.use('style-resource')
        .loader('style-resources-loader')
        .options({
            patterns: [
                path.resolve(__dirname, './src/assets/css/common.styl')
            ],
        })
}
